package com.renchi.menu.User.controller;

import com.renchi.menu.User.entity.UserDbEntity;
import com.renchi.menu.User.service.UserDbService;
import com.renchi.menu.common.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "user")
public class UserDbController {
    @Autowired
    private UserDbService userDbService;

    /**
     * 获取用户openid
     * @param code
     * @return
     */
    @RequestMapping(value = "getOpenid")
    public Result getOpenid(@RequestParam("code") String code){
        return userDbService.getOpenid(code);
    }

    /**
     * 保存用户
     * @param userDbEntity
     * @return
     */
    @RequestMapping(value = "saveUser",method = RequestMethod.POST)
    public Result saveUser(UserDbEntity userDbEntity){
        return userDbService.saveUser(userDbEntity);
    }

    /**
     * 删除用户
     * @param user_id
     * @return
     */
    @RequestMapping(value = "delUser",method = RequestMethod.GET)
    public Result delUser(@RequestParam("user_id") String user_id){
        return userDbService.delUser(user_id);
    }
}
